package	hottargui.domain.standard;

import hottargui.domain.*;

/** Standard tile implementation. */

public class StandardTile implements ModifiableTile {

	protected Position position;
	protected TileType type;
	protected PlayerColor player;

	/* Decleration added by group */

	private int _economicValue;
	private int _strategicValue;

	/** number of units on this tile */
	private int unit;

	public StandardTile(TileType t, PlayerColor p, int r, int c) {
		position = new Position(r,c);
		type = t;
		player = p;
		unit = 0;
		this.setEconomicValue(t);
		this.setStrategicValue(t);

	}

	public void changeUnitCount( int newValue ) {
		unit = newValue;
	}
	public void changePlayerColor( PlayerColor newColor ) {
		player = newColor;
	}
	public Position getPosition() { return position; }
	public PlayerColor getOwnerColor() { return player; }
	public int getUnitCount() { return unit; }
	public TileType getType() { return type; }

	public String toString() {
		return "Tile ("+position.getRow()+","+position.getColumn()+") "+
		"units="+ unit;
	}

	/* Generic methods implemented by group */

	public void setUnitCount(int unitCount) {
		unit = unitCount;
	}


	/** sets  the color of the Player who owns this tile   
	 */
	public void setOwnerColor(PlayerColor playerColor) {
		player = playerColor;
	}


	/* Implementation added by group */
	public int getEconomicValue() {
		return _economicValue;
	}


	/** returns the strategic value of this tile.
	 * @return the strategic value of this tile.
	 */
	public int getStrategicValue() {
		return _strategicValue;
	}


	private void setEconomicValue(TileType t) {

		if (t == TileType.Settlement) {
			_economicValue = 4;
		}	
		else if (t == TileType.Saltmine) {
			_economicValue = 5; 
		}
		else if (t == TileType.Oasis) {
			_economicValue = 3;   	
		}	
		else if (t == TileType.Erg) {
			_economicValue = 1;   
		}	
		else if (t == TileType.Reg) {
			_economicValue = 2;   	
		}	
		else if (t == TileType.Feshfesh) {
			_economicValue = 0;   	
		}	
		else if (t == TileType.Mountain) {
			_economicValue = 0;   	
		}	
		else if (t == TileType.Saltlake) {
			_economicValue = 0;   	
		}	
	}

	private void setStrategicValue(TileType t) {


		if (t == TileType.Settlement) {
			_strategicValue = 4;
		}	
		else if (t == TileType.Saltmine) {
			_strategicValue = 5; 
		}
		else if (t == TileType.Oasis) {
			_strategicValue  = 3;   	
		}	
		else if (t == TileType.Erg) {
			_strategicValue  = 0;   	
		}	
		else if (t == TileType.Reg) {
			_strategicValue = 0;   	
		}	
		else if (t == TileType.Feshfesh) {
			_strategicValue  = 2;   	
		}	
		else if (t == TileType.Mountain) {
			_strategicValue  = 1;   	
		}	
		else if (t == TileType.Saltlake) {
			_strategicValue  = 0;   	
		}	
	}





}
